<template>
<div class="company-help">
  <classList></classList>
      <section class="introduction">
          <div class="title">
        <p>作业历史记录</p>
      </div>
  <el-table
    ref="publishList"
    :data="publishList"
    border
    highlight-current
    :default-sort = "{prop: 'gmtCreate', order: 'Ascending'}"
  >
    <el-table-column
      prop="name"
      label="作业名称"
      width="200">
    </el-table-column>
    <el-table-column
      prop="intro"
      width="400"
      label="介绍">
    </el-table-column>
    <el-table-column
      label="开始时间"
      prop="gmtStart"
      width="200">
    </el-table-column>
    <el-table-column
      label="结束时间"
      prop="gmtFinish"
      width="200">
    </el-table-column>
    <el-table-column
      label="创建时间"
      prop="gmtCreate"
      width="200">
    </el-table-column>
    <el-table-column
      label="使用次数"
      prop="useCount"
    >
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="120">
      <template slot-scope="scope">
        <el-button
          type="text"
          size="small"
          @click="getPublishInfo(scope.row.id)">
          查看
        </el-button>
        <el-button
          type="text"
          size="small"
          @click="deletePublish(scope.row.id)">
          删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
<!-- 分页 -->
<el-pagination
  :current-page="page"
  :page-size="limit"
  :total="total"
  style="padding: 30px 0; text-align: center;"
  layout="total, prev, pager, next, jumper"
  @current-change=""
/>
 
      </section>
</div>
</template>

<script>
import classList from 'views/comp/classList'
// import cookie from "js-cookie";
 import publish from "api/publish";
export default {
name: "publishList",
components:{
classList
},
  created() {
 this.loginInfo = this.$store.state.userinfo
     this.init()
  },
  data(){
  return{

    loginInfo:{},
    limit:10,
    total:0,
    page:0,
    searchObj:{},
    publishList:[],
    courseList:[],
    classList:[],
    folderList:[],
  }
  },
    computed: {
      isFollowByClassId () {
        return this.$store.state.userinfo.classId;　　//需要监听的数据
      },
        isFollowByTeacherGroupId () {
        return this.$store.state.userinfo.teacherGroupId;　　//需要监听的数据
      }
    },
    watch: {
      isFollowByClassId (newVal, oldVal) {
   
        this.getPublishInfoByClassId(newVal)
      },
      isFollowByTeacherGroupId(newVal, oldVal){
          this.getPublishInfoByTeacherGroupId(newVal)
      }
    },
  methods:{
    deletePublish(id){
      publish.deleteById(id).then(res=>{
        this.$message({
          type: 'success',
          message: "删除成功"
        })
      })
    },
    init(){
      publish.getPublishByTeacherId(this.loginInfo.id).then(res=>{
        this.publishList=res.data.data.publishlist
      })
    },
    getPublishInfoByid(id){
      publish.getPublishInfo(id).then(res=>{
        this.courseList=res.data.data.courseList
        this.classList=res.data.data.classList
        this.folderList=res.data.data.folderList
       this.dialogPublishInfoVisible=true
      })
    },
    getPublishInfoByClassId(id){
this.searchObj.classId=id
      publish.getPublishList(this.page,this.limit,this.searchObj).then(res=>{
 this.publishList=res.data.data.publishList
 this.total=res.data.data.total
 this.searchObj.classId=''
      })
    },
    getPublishInfoByTeacherGroupId(id){

    }
  }
}
</script>


<style lang="stylus" scoped>
  .company-help {
    background: #e4e5e6;
    .user-info {
      font-size: 14px;
      background: #fafafa;
      margin-bottom: 20px;
      .title {
        background: #f0f1f3;
        height: 36px;
        line-height: 36px;
        p {
          display inline-block;
          height: 16px;
          line-height 16px;
          margin: 0 6px 0px 12px;
          padding-left: 6px;
          border-left: solid 4px #057ab8;
          vertical-align middle;
        }
      }
      .info {
        padding: 10px 0 10px 30px;
        .logo {
          display inline-block;
          width: 60px;
          height: 60px;
          margin-top: 8px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .info-right {
          display: inline-block;
          padding-top: 8px;
          min-height: 76px;
          line-height: 22px;
          margin-left: 12px;
          vertical-align: top;
          .account {
            font-weight: bold;
          }
        }
      }
    }
    .introduction {
      font-size: 14px;
      background: #fafafa;
      margin-bottom: 38px;
      .title {
        background: #f0f1f3;
        height: 36px;
        line-height: 36px;
        p {
          display inline-block;
          height: 16px;
          line-height 16px;
          margin: 0 6px 0px 12px;
          padding-left: 6px;
          border-left: solid 4px #057ab8;
          vertical-align middle;
        }
      }
      .intro {
        padding: 10px 0 10px 30px;
        li {
          padding: 10px;
          .icon-search {
            display:inline-block;
            width: 52px;
            height: 52px;
             background-image: url('/views/comp/features.png');
            background-position: 0 0;
          }
          .intro-detail {
            display: inline-block;
            margin-left: 12px;
            line-height: 20px;
            font-size: 12px;
            vertical-align: top;
            .intro-title {
              color: #0079bd;
              cursor: pointer;
            }
          }
        }
      }
    }
  }
</style>

